package com.dykj.fireFighting.server.base.maintenanceplan.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dykj.fireFighting.api.base.maintenanceplan.dto.MaintenancePlanDto;
import com.dykj.fireFighting.api.base.maintenanceplan.entity.MaintenancePlan;
import com.dykj.fireFighting.api.base.maintenanceplan.service.IMaintenancePlanService;
import com.dykj.fireFighting.api.base.maintenanceplan.vo.MaintenancePlanVo;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.server.base.maintenanceplan.mapper.MaintenancePlanMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;


import java.util.HashMap;

/**
 *
 *
 * @Author zly
 * @Date  2021-07-27 09:29:23
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanMapper, MaintenancePlan> implements IMaintenancePlanService {


    @Override
    public PageVo<MaintenancePlan> queryList(MaintenancePlanDto maintenancePlanDto) {

        HashMap<String, Object> params = new HashMap<>(16);
        params.put("maintenanceName",maintenancePlanDto.getMaintenanceName());
        params.put("beginTime",maintenancePlanDto.getBeginTime());
        params.put("endTime",maintenancePlanDto.getEndTime());
        params.put("maintenanceDept",maintenancePlanDto.getMaintenanceDept());
        params.put("socialUnitId",maintenancePlanDto.getSocialUnitId());
        params.put("contractNum",maintenancePlanDto.getContractNum());
        Page page = new Page();
        // 设置当前页码
        page.setCurrent(maintenancePlanDto.getPage());
        // 设置页大小
        page.setSize(maintenancePlanDto.getLimit());

        return new PageVo<MaintenancePlan>(this.baseMapper.queryList(page,params));
    }

    @Override
    public PageVo<MaintenancePlanVo> queryWarnList(MaintenancePlanDto maintenancePlanDto) {
        HashMap<String, Object> params = new HashMap<>(16);
        params.put("maintenanceName",maintenancePlanDto.getMaintenanceName());
        params.put("maintenanceDept",maintenancePlanDto.getMaintenanceDept());
        params.put("socialUnitId",maintenancePlanDto.getSocialUnitId());
        params.put("beginTime",maintenancePlanDto.getBeginTime());
        params.put("endTime",maintenancePlanDto.getEndTime());
        params.put("contractNum",maintenancePlanDto.getContractNum());
        Page page = new Page();
        // 设置当前页码
        page.setCurrent(maintenancePlanDto.getPage());
        // 设置页大小
        page.setSize(maintenancePlanDto.getLimit());

        return new PageVo<MaintenancePlanVo>(this.baseMapper.queryWarnList(page,params));
    }
}
